<?php
class Charts extends CI_Controller {
 
	public function __construct() {
		parent::__construct();
		$this->load->library('FusionCharts');
	}
 
	public function index() {
		$this->load->view('charts_index');
	}
 
	public function getData($year='2010') {
 
		// Instantiate the FusionCharts object 
		$FC = new FusionCharts(); 
 
		// specify the graph parameters
		$strParam="caption=Quarterly Sales for ".$year.";xAxisName=Quarter;yAxisName=Revenue;numberPrefix=$;decimalPrecision=0;formatNumberScale=1";
		$FC->setChartParams($strParam);
 
		// specify the data bsaed on the $year parameter
		if ($year=='2010') {
			$FC->addChartData("40800","name=Q1");
			$FC->addChartData("31400","name=Q2");
			$FC->addChartData("26700","name=Q3");
			$FC->addChartData("54400","name=Q4");
		} else {	
			$FC->addChartData("800","name=Q1");
			$FC->addChartData("400","name=Q2");
			$FC->addChartData("700","name=Q3");
			$FC->addChartData("200","name=Q4");
		}
		// output the FusionCharts XML
		print $FC->getXML();
	}
}
?>